import serial
import time
#设置串口、波特率以及发送数据间隔
ser = serial.Serial("/dev/ttyUSB1",9600,timeout=0.01)
while True:
    printData = bytearray()
    #0xaa
    printData.append(170)
    #0x55
    printData.append(85)
    #选择模式：手动/自动
    Data1 = int(input(" 1---Auto 2---Handle\nyour select:"))
    printData.append(Data1)
    #选择设备
    Data2 = int(input(" 1---Fan1 2---Fan2 3---Light 4---Motor\nyour deviceID:"))
    printData.append(Data2)
    #设定数值
    Data3 = int(input("your Value:"))
    printData.append(Data3//10)
    printData.append(Data3%10)
    # revise
    Data4 = int(input("revise:"))
    printData.append(Data4)
    # time
    Data5 = int(input("time:"))
    printData.append(Data5//10)
    printData.append(Data5%10)
    ser.write(printData)
    ser.flush()